import type { Recordable } from '@vben/types';

import { requestSystemClient } from '#/api/request';

export namespace SystemRoleApi {
  export interface SystemRole {
    [key: string]: any;
    roleId: number;
    roleName: string;
    roleCode: string;
    showSort: number;
    dataScope: number;
    dataScopeDeptIds: number[];
    roleStatus: number;
    roleType: number;
    remark?: string;
  }
}

/**
 * 获取角色列表数据
 */
async function getRoleList(params: Recordable<any>) {
  return requestSystemClient.get<Array<SystemRoleApi.SystemRole>>(
    '/system/role/page',
    { params },
  );
}

/**
 * 创建角色
 * @param data 角色数据
 */
async function createRole(data: Omit<SystemRoleApi.SystemRole, 'roleId'>) {
  return requestSystemClient.post('/system/role/create', data);
}

/**
 * 更新角色
 *
 * @param id 角色 ID
 * @param data 角色数据
 */
async function updateRole(data: Omit<SystemRoleApi.SystemRole, 'roleId'>) {
  return requestSystemClient.put(`/system/role/update`, data);
}

/**
 * 删除角色
 * @param id 角色 ID
 */
async function deleteRole(roleId: number) {
  return requestSystemClient.delete(`/system/role/delete/${roleId}`);
}
async function getRole(roleId: number) {
  return requestSystemClient.get(`/system/role/get/${roleId}`);
}
export { createRole, deleteRole, getRole, getRoleList, updateRole };
